/*
 * Copyright (C) 2008 by Xume.
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package org.xume.critann.annotations.criterion;

import java.lang.annotation.Annotation;

/**
 * $Id: CriterionType.java 26 2008-10-16 12:45:35Z johan.siebens $
 * 
 * @author Johan Siebens
 */
public enum CriterionType {

	EQ(new EqStrategy()), // 
	GE(new GeStrategy()), //
	GT(new GtStrategy()), //
	LE(new LeStrategy()), //
	LIKE(new LikeStrategy()), //
	LT(new LtStrategy()), //
	NE(new NeStrategy());

	private Strategy<?> strategy;

	private CriterionType(Strategy<?> strategy) {
		this.strategy = strategy;
	}

	public GenericCriterionCallback<?> createCallback() {
		return strategy.createCallback();
	}

	private static class EqStrategy implements Strategy<Eq> {

		public GenericCriterionCallback<Eq> createCallback() {
			return new EqCallback();
		}
	}

	private static class GeStrategy implements Strategy<Ge> {

		public GenericCriterionCallback<Ge> createCallback() {
			return new GeCallback();
		}
	}

	private static class GtStrategy implements Strategy<Gt> {

		public GenericCriterionCallback<Gt> createCallback() {
			return new GtCallback();
		}
	}

	private static class LeStrategy implements Strategy<Le> {

		public GenericCriterionCallback<Le> createCallback() {
			return new LeCallback();
		}
	}

	private static class LikeStrategy implements Strategy<Like> {

		public GenericCriterionCallback<Like> createCallback() {
			return new LikeCallback();
		}
	}

	private static class LtStrategy implements Strategy<Lt> {

		public GenericCriterionCallback<Lt> createCallback() {
			return new LtCallback();
		}
	}

	private static class NeStrategy implements Strategy<Ne> {

		public GenericCriterionCallback<Ne> createCallback() {
			return new NeCallback();
		}
	}

	private static interface Strategy<A extends Annotation> {

		GenericCriterionCallback<A> createCallback();
	}
}
